import time
from time import sleep
from selenium.webdriver.common.by import By
from common.base import Base
from common.functions import open_browser


class OthersInfoPage(Base):
    # 点击商品管理标签
    def click_goods_management(self):
        self.base_click((By.XPATH, '//div[@id="menu-list"]/ul/li[2]'))

    # 点击添加新商品标签
    def click_add_new_goods(self):
        self.base_click((By.LINK_TEXT, '添加新商品'))

    # 点击其他信息按钮
    def click_goods_others(self):
        self.base_switch_default_iframe()
        self.base_switch_iframe((By.ID, 'main-frame'))
        self.base_click((By.ID, "mix-tab"))

    # 输入商品重量
    def goods_weight(self, content):
        self.base_send_keys((By.NAME, "goods_weight"), content)

    # 商品重量下拉框选择
    def weight_unit(self, text):
        self.base_select_text((By.NAME, "weight_unit"), text)

    # 填写商品库存数量
    def goods_number(self, content):
        self.base_select_all((By.NAME, "goods_number"))
        self.base_send_keys((By.NAME, "goods_number"), content)

    # 填写库存警告数量
    def warn_number(self, content):
        self.base_select_all((By.NAME, "warn_number"))
        self.base_send_keys((By.NAME, "warn_number"), content)

    # 加入推荐-精品
    def goods_est(self):
        self.base_click((By.NAME, "is_best"))

    # 加入推荐-新品
    def goods_new(self):
        self.base_click((By.NAME, "is_new"))

    # 加入推荐-热销
    def goods_hot(self):
        self.base_click((By.NAME, "is_hot"))

    # 上架点击
    def on_sale(self):
        self.base_click((By.NAME, "is_on_sale"))

    # 作为普通商品销售点击
    def alone_sale(self):
        self.base_click((By.NAME, "is_alone_sale"))

    # 是否为免运费商品点击
    def is_shipping(self):
        self.base_click((By.NAME, "is_shipping"))

    # 填写商品关键词
    def goods_keywords(self, content):
        self.base_send_keys((By.NAME, "keywords"), content)

    # 填写商品描述
    def goods_desc(self, content):
        self.base_send_keys((By.NAME, "goods_brief"), content)

    # 填写商家备注
    def goods_notes(self, content):
        self.base_send_keys((By.NAME, "seller_note"), content)

    # 确定按钮
    def sure(self):
        self.base_click((By.XPATH, "//div[@class='button-div']/input[2]"))

    # 重置按钮
    def reset(self):
        self.base_click((By.XPATH, "//div[@class='button-div']/input[3]"))

